$(function(){
	layui.use(['form', 'layedit', 'laydate'], function(){
		  var form = layui.form
		  ,layer = layui.layer
		  ,layedit = layui.layedit
		  ,laydate = layui.laydate;
		  //日期
		  laydate.render({
		    elem: '#date'
		  });
		  laydate.render({
		    elem: '#date1'
		  });
		  form.on('select(mailType)', function(data){
			if(data['value']=='1'){
				$("input[name='reAddress']").parent().parent().show();
				$("input[name='rePort']").parent().parent().show();
				$("input[name='sendAddress']").parent().parent().show();
				$("input[name='sendPort']").parent().parent().show();
			}else{
				$("input[name='reAddress']").parent().parent().hide();
				$("input[name='rePort']").parent().parent().hide();
				$("input[name='sendAddress']").parent().parent().hide();
				$("input[name='sendPort']").parent().parent().hide();
			}
		  });
		  //监听提交
		  form.on('submit(demo1)', function(data){
				$.ajax({
					type : "POST",
					url : "/mail/emailAddAccountDo",
					data:$("form").serialize(),
					async : true,
					success : function(msg) {
						msg=JSON.parse(msg);
					    layer.alert(msg['msg'], {
					      title: '消息'
					    });
					},
					error : function() {
						
					}
				});
		    return false;
		  });
		  
		 
		});
});